package com.geek.bulk.echo;

import org.eclipse.microprofile.faulttolerance.*;

import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.Future;

public interface Echo {
  @Bulkhead(value = 1)
  void echo(String message);


  @Asynchronous
  Future echo(Integer message);


  @Fallback(value = EchoFallBackService.class)
  default void echo(Byte message) {
    System.out.println("echo");
  }

  /**
   * @see com.geek.bulk.interceptor.BulkInterceptorTest#testChainInterceptor()
   */
  @Retry(jitter = 500,retryOn = RuntimeException.class)
  @Timeout(value = 3000)
  void echo(Long message);

  @CircuitBreaker(requestVolumeThreshold = 2, delay = 1000, failOn = {InvocationTargetException.class})
  default void echo(Character character) {
    System.out.println("character = " + (int)character);
    throw new RuntimeException();
  }
}
